// 根路径
window.rootPath = (function (src) {
	src = document.currentScript
		? document.currentScript.src
		: document.scripts[document.scripts.length - 1].src;
	return src.substring(0, src.lastIndexOf("/") + 1);
})();
// 加载是否后端
var dev = true;
// 加载 layui
var layuiuse = ['admin', 'kahtml', 'dropdown', 'form', 'button', 'popup', 'watermark', 'kaPublic', 'jquery', 'cropper', 'kaCroppers' , 'cookie', 'qrcode', 'kaAjax',  'kaCurrentUser', 'kaBgUrl', "kaInterval", "util", "kaLog", "table", "kaLanguage", 'kaMsg', 'kaForm', 'kaToken', 'kaCookie', 'kaLayer', 'kaHtmlStatic', 'kaStepTabs', 'kaPhonenVerCode', 'formDesigner', 'HandwrittenSignature', 'kaGrid', 'kaGridData', 'kaGridCols', 'kaGridListHeaderMenu', 'kaGridTopButton', 'kaGridEndButton', 'kaGridHeaders', 'kaGridSearch', 'kaGridWhere', 'kaGridColsTemplet', 'kaGridColsTempletLoadJs', 'cardTable', 'kaTree', 'jqueryUi', 'kaFile'];
// 请求路径
var kaCtx = {
	top: function () {//头部
		return location.protocol + '//' + location.hostname;
	},
	qd: function () {//正式
		return kaCtx.top() + ":83";
	},
	location: function () {//本地
		return kaCtx.top() + ":81";
	},
	file: function () {//文件请求
		return kaCtx.top() + ":8012";
	},
	ai: function () {//AI 请求
		return kaCtx.top() + ":3001";
	},
	socket: function () {// Socket
		return location.hostname;
	}
}
var kaValue = {
	clt: function () {//当前语言
		var currentLanguage = localStorage.getItem("kaLanguageTypeCurrent");
		if (currentLanguage != undefined && currentLanguage != null && currentLanguage != "") {
			return currentLanguage;
		} else {
			currentLanguage = "1";
			localStorage.setItem("kaLanguageTypeCurrent", currentLanguage);
			return currentLanguage;
		}
	},
	clv: function () {//当前语言Value
		var currentLanguageValue = localStorage.getItem("kaLanguageValue");
		if (currentLanguageValue != undefined && currentLanguageValue != null && currentLanguageValue != "kaLanguageValue" && currentLanguageValue != "") {
			return JSON.parse(currentLanguageValue);
		} else {
			var kaLanguage = layui.kaLanguage;
			kaLanguage.loadingValue(kaValue.clt())
			return JSON.parse(localStorage.getItem("kaLanguageValue"));
		}
	}
}
//后端请求
function getKaContentType(type) {
	var contentTypeData = {
		"formUrlencoded": "application/x-www-form-urlencoded;charset=UTF-8",
		"json": "application/json;charset=UTF-8",
		"xml": "application/xml;charset=utf-8",
		"html": "text/html;charset=utf-8"
	};
	return contentTypeData[type];
}
function getKaDataType(dataType) {
	return (dataType == "json" || dataType == "formUrlencoded") ? "json" : (dataType == "html") ? "html" : "text";
}
// 后端页面路径
var kaBgPath = {
	kahtml: ""
};
// 后端请求所有 URL
var kaBgUrlJosn = {
	"url": kaCtx.location() + "/monitor/logininfor/getKaBgUrlData",
	"async": false,
	"methodType": "POST",
	"contentType": "json"
};
// 注册主键ID
var kaRegisterPrimaryKey = {
	registerId: function (ids) {
		var dataJson = [];
		for (var i in ids) {
			var id = ids[i];
			if (kaRegisterPrimaryKey.verifyId(id)) {
				dataJson.push({ "judge": true, "id": id });
			} else {
				return { "judge": false, "id": ids, "msg": "" };
			}
		}
		return { "judge": true, "ids": ids };
	},
	verifyId: function (id) {
		return true;
	}
}
// Interval All 数据
var intervalData = {
	"phonenVerCodeButton": {
		"value": null,
		"time": null
	},
	"scanCodeWaitInterval": {
		"value": null,
		"time": null
	},
	"jumpCountdown": {
		"value": null,
		"time": null
	},
	"previewText": {
		"value": null,
		"time": null
	}
}
// 日志Type  
var kaLogBoolean = 1; // 0:不打印 1：打印， 2：打印所有信息并保存后台， 3：打印所有信息并错误信息保存后台，4：打印错误信息并错误信息保存后台
var kaLogUrl = "saveLog"; // 后台保存
// 水印配置
function loadingWatermark(watermark, initOption) {
	var text = "KaUltra Admin 4.0";  //水印内容
	var fontSize = 20; //水印字体大小
	var rotate = 35; //水印旋转角度
	var spaceX = 100; //水印水平间隔
	var spaceY = 100; //水印垂直间隔
	if (initOption == undefined || initOption == null || initOption == "") {
		initOption = {
			text: text,  //水印内容
			fontSize: fontSize,  //水印字体大小
			rotate: rotate,  //水印旋转角度
			spaceX: spaceX,  //水印水平间隔
			spaceY: spaceY,  //水印垂直间隔
		}
	} else {
		initOption.text = text;
		initOption.rotate = rotate;
		initOption.spaceX = spaceX;
		initOption.spaceY = spaceY;
	}
	if (initOption.color == undefined || initOption.color == null || initOption.color == "") {
		initOption.color = "#000"; //水印字体颜色
	}
	if (initOption.opacity == undefined || initOption.opacity == null || initOption.opacity == "") {
		initOption.opacity = 0.1; //水印透明度
	}
	watermark.init(initOption);
}
//Token 设置
var kaTokenName = "ka_token";
var getkaTokenUrl = "getToken";
var kaTokenEndTime = 2 * 60 * 60 * 1000;
//当前用户
var currentUser = {};
//記住賬號名稱
var loginAutomaticLogonName = "ka_automatic_logon";
// 配置脚本主键
layui.config({
	base: rootPath + "module/",
	version: "4.0.3"
}).extend({
	admin: "admin",
	cropper: "cropper",
	page: "page",
	tabPage: "tabPage",
	menu: "menu",
	fullscreen: "fullscreen",
	menuSearch: "menuSearch",
	button: "button",
	tools: "tools",
	HandwrittenSignature: "HandwrittenSignature",
	kaPublic: "kaPublic",
	kaInterval: "kaInterval",
	kaMsg: "kaMsg",
	kahtml: "kahtml",
	qrcode: "kaQrcode",
	cardTable: "cardTable",
	kaPinYin: "kaPinYin",
	kaBgUrl: "kaBgUrl",
	kaAjax: "kaAjax",
	kaToken: "kaToken",
	kaCookie: "kaCookie",
	jqueryUi: "jqueryUi",
	kaPreviewText: "kaPreviewText",
	kaLog: "kaLog",
	kaForm: "kaForm",
	kaLanguage: "kaLanguage",
	kaMsg: "kaMsg",
	kaFile: "kaFile",
	kaLayer: "kaLayer",
	kaHtmlStatic: "kaHtmlStatic",
	kaStepTabs: "kaStepTabs",
	kaPhonenVerCode: "kaPhonenVerCode",
	kaCropper: "kaCropper",
	kaGridCols: "kaGridCols",
	kaGridData: "kaGridData",
	kaGridListHeaderMenu: "kaGridListHeaderMenu",
	kaGridTopButton: "kaGridTopButton",
	kaGridEndButton: "kaGridEndButton",
	kaGridHeaders: "kaGridHeaders",
	kaGridWhere: "kaGridWhere",
	kaGridSearch: "kaGridSearch",
	kaGridColsTemplet: "kaGridColsTemplet",
	kaGridColsTempletLoadJs: "kaGridColsTempletLoadJs",
	kaGrid: "kaGrid",
	kaTree: "kaTree",
	popup: "extends/popup",
	count: "extends/count",
	toast: "extends/toast",
	nprogress: "extends/nprogress",
	echarts: "extends/echarts",
	echartsTheme: "extends/echartsTheme",
	yaml: "extends/yaml"
}).use([], function () { });